package bean.dao;

import java.util.ArrayList;
import java.util.List;

import org.hibernate.Session;
import org.hibernate.Transaction;

import Entities.Factura;

public class FacturaDAO extends HibernateDAO{

	public void altaFactura(Factura c )
	{
		Session s = HibernateDAO.getInstancia().getSession();
		Transaction t = s.beginTransaction();
		s.save(c);
		t.commit();
	}
	
	public void guardarFactura(Factura factura) {
		  Session s = HibernateDAO.getInstancia().getSession();
		  Transaction t = s.beginTransaction();
		  s.save(factura);
		  t.commit();
	}

	@SuppressWarnings("unchecked")
	public List<Factura> getFacturas() {
		
		List<Factura> facturas = new ArrayList<Factura>();
		  Session s = HibernateDAO.getInstancia().getSession();
		  Transaction t = s.beginTransaction();
		  facturas= s.createQuery("from Factura").list();	
		  t.commit();
		return facturas;
	}
	
	
	
}